Loosing module context

Hello,

I am chasing links (both in and out links) from a module to the linked module using a function call. I grab some data from the linked module, and when I return from the function call, I suddenly start getting errors about non-existant attributes in the original module. It appears that I've lost context somehow. (The attributes do exist in the original module, but not in the linked to module.) In the function, I open the linked module for reading. If I close that module before returning from the function, I now get errors about not having a current module!

Do I need to save the name and current object of the module I started in before chasing the links?

I am using DOORS 9.2 currently. The original module is opened as read only. This seems to happen for both in-links and out-links. Anyone know what's going on here? I've gotten such great responses here, so rather than beat my head against the desk again today, I thought I'd ask ;-)

Thanks in advance! (I can post the code if that's needed...)

-Steve
SteveK01 - Wed Mar 10 13:24:11 EST 2010

Re: Loosing module context
doors36677 - Wed Mar 10 13:38:41 EST 2010

When you open a module use read, edit or share you change the current module.

Re: Loosing module context
SteveK01 - Wed Mar 10 13:43:10 EST 2010

doors36677 - Wed Mar 10 13:38:41 EST 2010
When you open a module use read, edit or share you change the current module.

Ah, ok. So the new read context isn't local to the function call then. Bummer. Guess that answers my question. Thanks.

-Steve

Re: Loosing module context
llandale - Wed Mar 10 18:10:36 EST 2010

This is a common problem. I don't recall the EXACT situation when the 'current' module changes, but believe its when the other module is actually opened, but doesn't change when the other module is already open, and you try again.

In any case there is no reason why the top of your scripts should not have something like this:

Module g_mOriginal = current
>>> if (null g_mOriginal)
{errorBox("run from open module"); halt}
or this>>> if (!null g_mOriginal)
{errorBox("Run from Folder, not a module"); halt}

Use that module handle, rarely the 'current Module'.

When you use functions that presume the 'current Module', you should do something like this:

Module mCurr = current
Current = g_mOriginal
ad = find()
if (!null mCurr) current = mCurr

That will preserve the 'current Module', whatever it is.

  • Louie

Actually, the rules changed on me I think from v5 to v6 which messed up my DXL, prompting me to use the standard stuff above.